﻿/*
 * Copyright 2014 Francois Karman
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Quartz.WebManager.Model
{
    /// <summary>
    /// Tests the <see cref="Trigger"/> class.
    /// </summary>
    [TestClass]
    public class TriggerTest
    {
        /// <summary>
        /// Tests the <see cref="Trigger"/> default constructor.
        /// </summary>
        [TestMethod]
        public void DefaultConstructor()
        {
            Trigger instance = new Trigger();
            Assert.AreEqual(5, instance.Priority);
            Assert.AreEqual(0, instance.MisfireInstruction);
        }

        /// <summary>
        /// Tests the <see cref="Trigger"/> initialized constructor.
        /// </summary>
        [TestMethod]
        public void InitializedConstructor()
        {
            Trigger instance = new Trigger()
            {
                CronExpression = "test cron expression",
                Description = "test description",
                Group = "test group",
                JobGroup = "test job group",
                JobName = "test job name",
                MisfireInstruction = 4,
                Name = "test name",
                Priority = 3,
                EndTime = new DateTime(2014, 1, 2, 3, 4, 5),
                StartTime = new DateTime(2014, 1, 2, 3, 4, 6),
            };

            Assert.AreEqual("test cron expression", instance.CronExpression);
            Assert.AreEqual("test description", instance.Description);
            Assert.AreEqual("test group", instance.Group);
            Assert.AreEqual("test job group", instance.JobGroup);
            Assert.AreEqual("test job name", instance.JobName);
            Assert.AreEqual(4, instance.MisfireInstruction);
            Assert.AreEqual("test name", instance.Name);
            Assert.AreEqual(3, instance.Priority);

            Assert.IsNotNull(instance.EndTime);
            Assert.IsNotNull(instance.StartTime);
            Assert.AreEqual(new DateTime(2014, 1, 2, 3, 4, 5), instance.EndTime.Value);
            Assert.AreEqual(new DateTime(2014, 1, 2, 3, 4, 6), instance.StartTime.Value);
        }
    }
}
